$(function(){
	//表单验证
	jQuery.validator.addMethod("isTel", function(value, element) {   
		var tel = /^1[34578]\d{9}$/;
		return this.optional(element) || (tel.test(value));
	});
// 	jQuery.validator.addMethod("isEmail", function(value, element) {   
// 		var emails = /^[A-Za-z0-9\u4e00-\u9fa5]+@@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/  ;
// 		return this.optional(element) || (emails.test(value));
// 	});
	$("#submitForm").validate({
		rules:{
			tel:{
				required: true,
				isTel:true
			},
			email: {
				required: true,
				email: true
			},
			require:{
				required: true,
				maxlength:300
			}
		},
		messages:{
			tel:{
				required:'请输入手机号码',
				isTel:'请输入正确的手机号码'
			},
			email:{
				required:'请输入邮箱',
				email:'请输入正确的邮箱格式'
			},
			require:{
				required:'请输入服务需求',
				maxlength:'不能超出300字'
			}
		},
		submitHandler:function(form){
			$(".tip").fadeIn();
			setTimeout(function(){
				$(".tip").fadeOut();
			},3000)
			$(".telBox input,.leavmsg textarea").val("");
		}
	})
	
	
	$(".wap_menu").click(function () {
	    $(".menu").toggleClass("on");
	})
	$('#fullpage').fullpage({
		anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],
		menu:'#myMenu',
		verticalCentered:false,
		resize:true,
		pagination:true,
		onLeave:function(index,nextIndex,direction){
			if(nextIndex==1){
				$(".header").css("background","rgba(4,47,103,0.5)");
			}else{
				$(".header").css("background","rgba(16,46,73,0.8)");
			}
		}
	});
	
	$(window).resize(function(){
		autoScrolling();
	});
	
	$(window).scroll(function(){
		var $ww = $(window).width();
		if($ww < 1025){
			if($(window).scrollTop()>100){
				$(".header").css("background","rgba(16,46,73,0.8)");
				return
			}
			
			if($(window).scrollTop()<100){
				$(".header").css("background","transparent");
				return
			}
		}
	})
	
	var owidth = $(window).width();
			
	if(owidth < 800){
		var mySwiper1 = new Swiper('.swiper2', {
			pagination: {
				el: '.pagination2',
				renderBullet: function (index, className) {
					switch(index){
						case 0:text='软件产品研发';break;
						case 1:text='咨询服务与解决方案';break;
						case 2:text='业务流程外包';break;
						case 3:text='企业解决方案';break;
						case 4:text='应用开发与维护';break;
						case 5:text='质量保证和测试';break;
					}
					return '<span style="font-size:12px" class="' + className + '">' + text + '</span>';
				},
			},
			thumbs: {
				swiper: {
				  el: '.swiper-container-thumbs',
				  slidesPerView: 1,
				  pagination: {
				  	el: '.pagination3',
				  },
				},
				slideThumbActiveClass: 'my-slide-thumb-active',
			}
		});
	}else{
		var mySwiper1 = new Swiper('.swiper2', {
			grabCursor : true,
			slidesPerView: 4,
			spaceBetween: 20
		});
	}

	function autoScrolling(){
		var $ww = $(window).width();
		if($ww < 1025){
			$(".menu ul li").click(function(){
				$(".menu").removeClass("on")
// 				$(this).addClass("active").siblings().removeClass("active")
// 				$(".menu ul li label").hide();
// 				$(this).find("label").show();
// 				var $index=$(this).index();
// 				if($index==0){
// 					scrollTo('#page1',0);
// 				} else if($index==1){
// 					scrollTo('#page2',0);
// 				}else if($index==2){
// 					scrollTo('#page3',0);
// 				}else if($index==3){
// 					scrollTo('#page4',0);
// 				}else if($index==4){
// 					scrollTo('#page5',0);
// 				}
			})
			$.fn.fullpage.setAutoScrolling(false);
			$(".section").css("height","initial")
		} else {
			
			$.fn.fullpage.setAutoScrolling(true);
			$(".section").css("height","100%")
		}
		
		
	}

	autoScrolling();
	
});

var mySwiper = new Swiper('.swiper1',{
	pagination: {
		el: '.pagination1',
	},
	navigation: {
		nextEl: '.swiper-button-next',
		prevEl: '.swiper-button-prev',
	},
	autoplay : {
		delay:5000,
		disableOnInteraction:false
	},
	grabCursor : true,
	speed:800,
	loop:true,
	effect : 'fade'
})

function scrollTo(ele, speed){
	if(!speed) speed = 300;
	if(!ele){
		$("html,body").animate({scrollTop:0},speed);
	}else{
		if(ele.length>0) $("html,body").animate({scrollTop:$(ele).offset().top-50},speed);
	}
	return false;
}



